﻿package  com.hadron.mp3player
{
	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author Hadron
	 */
	public class PlayerButton extends Sprite
	{
		public var normal:MovieClip;
		public var over:MovieClip;
		public var hit:MovieClip;
		
		public function PlayerButton() 
		{
			addEventListener(MouseEvent.ROLL_OVER, onOver, false, 0, true);
			addEventListener(MouseEvent.ROLL_OUT, onOut, false, 0, true);
			addEventListener(MouseEvent.MOUSE_DOWN, onDown, false, 0, true);
			addEventListener(MouseEvent.MOUSE_UP, onUp, false, 0, true);
			
			buttonMode = true;
			if (normal != null || over != null || hit != null)
			{
				normal.mouseEnabled = false;
				over.mouseEnabled = false;
				hit.mouseEnabled = false;
				addChild(normal);
			}
			
			
		}
		
		private function onOver(e:MouseEvent):void
		{
			if (over != null)
			{
				addChild(over);
			}
		}
		
		private function onOut(e:MouseEvent):void
		{
			if (over != null)
			{
				removeChild(over);
			}
		}
		
		private function onDown(e:MouseEvent):void
		{
			if (hit != null)
			{
				addChild(hit);
			}
		}
		
		private function onUp(e:MouseEvent):void
		{
			if (hit != null)
			{
				removeChild(hit);
			}
		}
	}
	
}